package xyz.dagoose.contacts;

public class arrTest {

	public static void main(String[] args) {
		String[] arr = new String[]{"22","qq","ww","mm","gg","boom","zi"};
		String[] arr2 = new String[arr.length];
		
		// 数组复制
		for(int i=0;i<arr2.length;++i){
			arr2[i] = arr[i];
		}
		
		// 数组反向
//		String temp;
		
//			// 方法一
//		for(int i = 0; i< arr2.length/2;i++){
//			temp = arr2[i];
//			arr2[i] = arr2[arr2.length-1-i];
//			arr2[arr2.length-1-i]=temp;
//		}
//			 //方法二
//		for(int i = 0,j =arr2.length-1 ; i < j;i++,j--){
//			temp = arr2[i];
//			arr2[i] = arr2[j];
//			arr2[j]=temp;
//		}
		
		// 遍历输出
		for(int i=0;i<arr2.length;i++)System.out.print(arr[i]+"  ");
		System.out.println();
		for(int i=0;i<arr2.length;i++)System.out.print(arr2[i]+"  ");
	
		
	
		// 线性查找
		String dest = "qq";
		boolean isFlag = true;
		for (int i=0;i<arr.length;i++){
			if(dest.equals(arr[i])){
				System.out.println("找到了位置是 "+(i+1));
				isFlag = false;
				break;
			}
		}
		if(isFlag)System.out.println("没找到");
		
		// 二分法 顺序查找
		int[] numArr = new int[]{1,2,4,5,7,12,19,22,46,53};
		int number = 22,middle = numArr.length/2;
		
	}
}
